<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/User.Master" Inherits="System.Web.Mvc.ViewPage<mesoBoard.Data.Message>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% if(Model != null){ %>

  <div class="post_body last_post">
        <div class="post_user">
        
            <% if(!string.IsNullOrEmpty(Model.UserFrom.UserProfile.Avatar)){ %>   
            <div class="post_user_avatar">
                <%= Html.UserAvatar(Model.FromUserID) %>
            </div>
            <%} %>
        
            <div class="post_username">
                <%= Html.UsernameLink(Model.UserFrom) %>
            </div>
            
            <div class="post_user_rank">
                <%= Html.UserRank(Model.UserFrom) %>
            </div>
            
            <ul class="post_user_details">
                <li>
                    <%= Html.ActionLink("Private Message", "SendMessage", "Messages", new { ToUserName = Model.UserFrom.Username }, "") %>
                </li>
                <li><%= Model.UserFrom.TotalPosts %> posts</li>
                <li>Joined: <%= Model.UserFrom.RegisterDate.ToString("MMM yyyy") %></li>
                <li>Location: <%= Model.UserFrom.UserProfile.Location %> </li>
            </ul>
        </div>
        
        <div class="post_text">
            <div class="post_date">
                <label style="display:block; font-size: 13px;font-weight:bold;padding-bottom:5px;"><%= Model.Subject %></label>
                from <b><%= Html.UserProfileLink(Model.UserFrom.Username) %></b> on <b><%= Html.RelativeDate(Model.DateSent) %></b>
                    <% if(int.Parse(User.Identity.Name) == Model.ToUserID){ %>
                        <div class="right">
                            <% Html.BeginForm("Inbox", "Messages", new { Box = "All" }); %>
                            <input type="hidden" value="<%= Model.MessageID %>" name="msgID" />
                            <input type="submit" value="Delete" name="DoAction" class="message_delete" />
                            <% Html.EndForm(); %>
                        </div>
                    <%} %>
            </div>
            <div style="margin-left: 10px; width: 100%;overflow-x: hidden">
                <%= Html.ParsePostText(Model.Text) %>
                <%= Html.Spacer(25) %>
                <div class="post_user_signature">
                    <%= Html.ParsePostText(Model.UserFrom.UserProfile.Signature) %>
                </div>               
            </div>
        </div>
    </div>

    <% if(int.Parse(User.Identity.Name) == Model.ToUserID){ %>
        <%= Html.Spacer(10) %>
        <% Html.BeginForm(); %>
        <table style="margin: 0 auto;width: auto" class="form_table" >
            <tr><th>Reply</th></tr>
            <tr>
                <td>Subject: <%= Html.TextBox("Subject", "RE: "+Model.Subject) %></td>
            </tr>
            <tr>
                <td>
                    Message:<br />
                    <%= Html.TextArea("ReplyMessage", new { cols = "60", rows = "7", @class="bbcode" })%>
                    <input type="hidden" value="<%= Model.MessageID %>" name="MessageID" />
                    <input type="hidden" value="<%= Model.FromUserID %>" name="MessageToUserID" />
                </td>
            </tr>
            <tr><th><input type="submit" value="Send Reply" /></th></tr>
        </table>
        <% Html.EndForm(); %>
    <%} %>
<%} %>
</asp:Content>
